package com.unionpay.mobile.android.pboctransaction.icfcc;

import android.content.Context;
import android.content.Intent;
import android.content.ServiceConnection;
import android.os.RemoteException;
import com.unionpay.mobile.android.pboctransaction.AppIdentification;
import com.unionpay.mobile.android.pboctransaction.d;
import com.unionpay.mobile.android.pboctransaction.e;
import com.unionpay.mobile.android.utils.h;
import java.util.ArrayList;

public final class a
  implements com.unionpay.mobile.android.pboctransaction.c
{
  private String a = null;
  private String b = "A0000003334355502D4D4F42494C45";
  private cn.gov.pbc.tsm.client.mobile.android.bank.service.a c;
  private com.unionpay.mobile.android.pboctransaction.b d;
  private Context e;
  private ServiceConnection f = new b(this);

  private static boolean a(String paramString)
  {
    return (paramString.startsWith("00A40400")) || (paramString.startsWith("01A40400")) || (paramString.startsWith("02A40400"));
  }

  private byte[] a(byte[] paramArrayOfByte)
  {
    try
    {
      String str = e.a(paramArrayOfByte, paramArrayOfByte.length);
      boolean bool1 = a(str);
      localObject = null;
      if (bool1)
      {
        if (!str.contains(this.a))
          break label109;
        h.c("icfcc", "pbocAID = " + this.a);
        byte[] arrayOfByte2 = this.c.a(e.a(this.a), "00");
        localObject = arrayOfByte2;
      }
      while (true)
      {
        h.c("icfcc", " openSEChannel result=" + e.a(localObject));
        return localObject;
        label109: boolean bool2 = str.contains(this.b);
        localObject = null;
        if (bool2)
        {
          h.c("icfcc", "upcardAID = " + this.b);
          byte[] arrayOfByte1 = this.c.a(e.a(this.b), "01");
          localObject = arrayOfByte1;
        }
      }
    }
    catch (Exception localException)
    {
      while (true)
        Object localObject = null;
    }
  }

  public final ArrayList<com.unionpay.mobile.android.model.c> a(d paramd)
  {
    if (this.c == null)
      return null;
    ArrayList localArrayList = new ArrayList();
    try
    {
      String str1 = c.a(e.a(this.c.a(e.a("325041592e5359532e4444463031"), "00")), "4F");
      h.c("icfcc", "aid =" + str1);
      if (str1 != null)
      {
        this.a = str1;
        AppIdentification localAppIdentification = new AppIdentification(str1, "");
        String str2 = e.c(paramd.a(localAppIdentification));
        if ((str2 != null) && (str2.length() > 0))
        {
          h.c("icfcc", "  " + str2);
          localArrayList.add(new com.unionpay.mobile.android.model.a(8, localAppIdentification.a(), "", str2, 1));
        }
      }
      try
      {
        this.c.b("00");
        return localArrayList;
      }
      catch (RemoteException localRemoteException3)
      {
        while (true)
          localRemoteException3.printStackTrace();
      }
    }
    catch (Exception localException)
    {
      localException = localException;
      try
      {
        this.c.b("00");
        return null;
      }
      catch (RemoteException localRemoteException2)
      {
        while (true)
          localRemoteException2.printStackTrace();
      }
    }
    finally
    {
    }
    try
    {
      this.c.b("00");
      throw localObject;
    }
    catch (RemoteException localRemoteException1)
    {
      while (true)
        localRemoteException1.printStackTrace();
    }
  }

  public final void a()
  {
    d();
    if (this.c != null);
    try
    {
      this.c.a();
      label21: if (this.e != null)
      {
        new Intent("com.unionpay.mobile.tsm.PBOCService");
        this.e.unbindService(this.f);
      }
      return;
    }
    catch (RemoteException localRemoteException)
    {
      while (true)
        localRemoteException.printStackTrace();
    }
    catch (Exception localException)
    {
      break label21;
    }
  }

  public final void a(com.unionpay.mobile.android.pboctransaction.b paramb, Context paramContext)
  {
    this.d = paramb;
    this.e = paramContext;
    Intent localIntent = new Intent("cn.gov.pbc.tsm.client.mobile.android.bank.service");
    localIntent.setPackage("cn.gov.pbc.tsm.client.mobile.andorid");
    paramContext.startService(localIntent);
    if ((!paramContext.bindService(localIntent, this.f, 1)) && (paramb != null))
    {
      h.a("icfcc", "startTSMService.initFailed()");
      paramb.b();
    }
  }

  public final byte[] a(byte[] paramArrayOfByte, int paramInt)
  {
    String str = e.a(paramArrayOfByte, paramArrayOfByte.length);
    h.c("icfcc", "====>" + str);
    if (this.c == null)
      return null;
    if (a(str))
      return a(paramArrayOfByte);
    try
    {
      byte[] arrayOfByte2 = this.c.b(paramArrayOfByte);
      arrayOfByte1 = arrayOfByte2;
      h.c("icfcc", "<====" + e.a(arrayOfByte1));
      return arrayOfByte1;
    }
    catch (Exception localException)
    {
      while (true)
        arrayOfByte1 = null;
    }
    catch (RemoteException localRemoteException)
    {
      while (true)
        byte[] arrayOfByte1 = null;
    }
  }

  public final void b()
  {
  }

  public final void c()
  {
  }

  public final void d()
  {
    if (this.c != null);
    try
    {
      this.c.b("00");
      this.c.b("01");
      return;
    }
    catch (RemoteException localRemoteException)
    {
      localRemoteException.printStackTrace();
      return;
    }
    catch (Exception localException)
    {
    }
  }
}

/* Location:           C:\Users\user\Desktop\dd28_pcdd720\classes_dex2jar.jar
 * Qualified Name:     com.unionpay.mobile.android.pboctransaction.icfcc.a
 * JD-Core Version:    0.6.2
 */